const express = require("express")
const app = express();
const path = require("path");

//处理body请求体的中间件
app.use(express.urlencoded())
app.use(express.json())


//jsonp请求接口
app.get("/userJsonp",(req,res)=>{
  const{
    cb
  } = req.query

  const data = {
        code: 10000,
        msg: "查询成功",
        data: {
          name: "韩立",
          age: 14300,
          sex: "男"
        }
      }

  res.send(`${cb}(${JSON.stringify(data)})`)
})


app.listen(3000, () => {
  console.log("服务器请求成功 请访问 http://127.0.0.1:3000");
})